﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Shapes;
using HalconDisplayControl;
using HalconDisplayControl.Shape;
using HalconDotNet;

namespace halconDisplay
{
    public partial class Form1 : Form
    {
        HDisplay hd;
        public Form1()
        {
            InitializeComponent();

            hd = new HDisplay();
            hd.Dock = DockStyle.Fill;
            panel1.Controls.Add(hd);
            hd.Drawed += Hd_Drawed;

            hd.HalconWindow.SetDraw("margin");
            hd.HalconWindow.SetColor("green");
            HOperatorSet.ReadImage(out HObject img, @"C:\Users\laoguo\Pictures\QQ图片20250618173832.jpg");
            hd.HalconWindow.DispObj(img);
        }

        private void Hd_Drawed(IShape shape)
        {
            shape.CreateShapeObj(out HObject obj);
            hd.HalconWindow.DispObj(obj);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            hd.Draw(new CircleShape());
        }
        private void button2_Click(object sender, EventArgs e)
        {
            hd.Draw(new Rectangle1Shape());
        }

        private void button3_Click(object sender, EventArgs e)
        {
            hd.Draw(new Rectangle2Shape());
        }

        private void button4_Click(object sender, EventArgs e)
        {
            hd.Draw(new CircleSectorShape());
        }

        private void button5_Click(object sender, EventArgs e)
        {
            hd.Draw(new XldShape());
        }

        private void button7_Click(object sender, EventArgs e)
        {
            hd.Draw(new EllipseShape());
        }

        private void button8_Click(object sender, EventArgs e)
        {
            hd.Draw(new EllipseSectorShape());
        }

        private void button6_Click(object sender, EventArgs e)
        {
            hd.Draw(new LineShape());   
        }
    }
}
